package edu.sctu.zhoudie.mouth201506.day20150609;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by user08 on 2015/6/9.
 */
public class TimeManeger {
    public void thenTime() {

        String time = "2012-07-12 17:30:30";
        Date date = null;
        SimpleDateFormat then = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            date = then.parse(time);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println("开始固定的时间" + then.format(date));
    }

    public void timeUse() {

        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 5);
        SimpleDateFormat now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        System.out.println("当前的时间：" + now.format(new Date()));
        System.out.println("五分钟后的时间：" + now.format(calendar.getTime()));

    }

    public static void main(String[] args) {
        TimeManeger timeManeger = new TimeManeger();
        timeManeger.thenTime();
        timeManeger.timeUse();
    }
}
